#include "Including.h"

using namespace std;

namespace Profiling{

	//calculate the current fps
	//t: the time of drawing one frame
	//the time of drawing 50 frames: t' = t * 50
	//fps = 1/t = 50/t'
	int MyProfiling::CallFrequency()
	{
		 static int count;
		 static int fps;
		 static clock_t last; 
		 static clock_t current;
		 float timegap;

		 ++count;

		 //whether 50 frames have been drawn
		 if( count <= 50 )
		     return fps;

		 count = 0;
		 last = current;
		 current = clock();
		 timegap = (current-last)/(float)CLK_TCK;
		 fps = 50/timegap;

		 return fps;
	}

}